| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | Static Public Member Functions | List of all members
nkAstraeus::DofComplexEffect Class Referencefinal

A Depth of Field effect. More...

Inheritance diagram for nkAstraeus::DofComplexEffect:

## Public Member Functions
| DofComplexEffect (System *system) noexcept
virtual | ~DofComplexEffect ()
nkGraphics::Texture * | getSourceTexture () const
nkGraphics::Texture * | getSourceDepth () const
nkGraphics::Texture * | getOutputTexture () const
nkGraphics::Camera * | getCamera () const
float | getNearPlaneDistance () const
float | getFocalPlaneDistance () const
float | getFocalPlaneThickness () const
float | getFarPlaneDistance () const
unsigned int | getBlurStrength () const
bool | getLinearDepth () const
void | setSourceTexture (nkGraphics::Texture *value)
void | setSourceDepth (nkGraphics::Texture *value)
void | setCamera (nkGraphics::Camera *value)
void | setNearPlaneDistance (float value)
void | setFocalPlaneDistance (float value)
void | setFocalPlaneThickness (float value)
void | setFarPlaneDistance (float value)
void | setBlurStrength (unsigned int value)
void | setLinearDepth (bool value)
virtual bool | load () override
virtual void | unload () override
Public Member Functions inherited from nkAstraeus::ComplexEffect
| ComplexEffect (COMPLEX_EFFECT_TYPE type) noexcept
virtual | ~ComplexEffect ()
nkMemory::StringView | getName () const
nkGraphics::CompositorNode * | getCompositorNode () const
COMPLEX_EFFECT_TYPE | getType () const
void | setName (nkMemory::StringView value)
void | setCompositorNode (nkGraphics::CompositorNode *value)

## Static Public Member Functions
static nkMemory::UniquePtr< DofComplexEffect > | create (System *system=nullptr)

## Detailed Description

A Depth of Field effect.

This effect will mimick the depth of field of a camera, and blur everything that is not in the focal plane. It is typically used to give a good sense of depth to an image, and can sometimes fool perception. For instance, a very narrow focal area (near and far close to each other) will make everything feel small, like small toys. It can also make obvious the parts that should attract attention, by focusing on the important objects in a given scene and blurring all its surrounding.

This effect works in a very straightforward way, by mapping world unit distances to the various planes defined. The near and far blur define zones where the pixels are fully blurred, respectively when too close or too far from the camera. The focal plane defines pixels that are in focus and thus, sharp, at the ideal distance from the camera. Anything in between will be interpolated between the blurry and sharp versions, depending on their distance from the focal plane boundaries.

## Constructor & Destructor Documentation

## ◆ DofComplexEffect()

nkAstraeus::DofComplexEffect::DofComplexEffect | ( | System * | system | ) |
| noexcept

Default constructor. Alternatively, see DofComplexEffect::create(), or ComplexEffectManager::createOrRetrieve().

Parameters

  system | The system the resource should live in.

## ◆ ~DofComplexEffect()

virtual nkAstraeus::DofComplexEffect::~DofComplexEffect | ( |  | ) |
| virtual

Default destructor.

## Member Function Documentation

## ◆ getSourceTexture()

nkGraphics::Texture* nkAstraeus::DofComplexEffect::getSourceTexture | ( |  | ) | const

Returns
  The source color texture used by the effect.

## ◆ getSourceDepth()

nkGraphics::Texture* nkAstraeus::DofComplexEffect::getSourceDepth | ( |  | ) | const

Returns
  The source depth texture used by the effect.

## ◆ getOutputTexture()

nkGraphics::Texture* nkAstraeus::DofComplexEffect::getOutputTexture | ( |  | ) | const

Returns
  The texture the effect will finally output to.

Remarks
  This texture is tied to the lifetime of the ComplexEffect it is linked to. It will be usable as long as the effect is alive and won't change even after loading operations.

## ◆ getCamera()

nkGraphics::Camera* nkAstraeus::DofComplexEffect::getCamera | ( |  | ) | const

Returns
  Current set camera.

## ◆ getNearPlaneDistance()

float nkAstraeus::DofComplexEffect::getNearPlaneDistance | ( |  | ) | const

Returns
  Current near plane distance.

## ◆ getFocalPlaneDistance()

float nkAstraeus::DofComplexEffect::getFocalPlaneDistance | ( |  | ) | const

Returns
  Current focal plane distance.

## ◆ getFocalPlaneThickness()

float nkAstraeus::DofComplexEffect::getFocalPlaneThickness | ( |  | ) | const

Returns
  Current focal plane's thickness.

## ◆ getFarPlaneDistance()

float nkAstraeus::DofComplexEffect::getFarPlaneDistance | ( |  | ) | const

Returns
  Current far plane distance.

## ◆ getBlurStrength()

unsigned int nkAstraeus::DofComplexEffect::getBlurStrength | ( |  | ) | const

Returns
  Current blurring strength.

## ◆ getLinearDepth()

bool nkAstraeus::DofComplexEffect::getLinearDepth | ( |  | ) | const

Returns
  Whether the depth data is considered linear (true) or not (false).

## ◆ setSourceTexture()

void nkAstraeus::DofComplexEffect::setSourceTexture | ( | nkGraphics::Texture * | value | ) |

Sets the texture to use as input to the effect.

Parameters

  value | The texture to use as input.

Remarks
  This parameter does not need a reload of the effect to be taken into account.

## ◆ setSourceDepth()

void nkAstraeus::DofComplexEffect::setSourceDepth | ( | nkGraphics::Texture * | value | ) |

Sets the depth texture to use as input to the effect.

Parameters

  value | The depth texture to use as input.

Remarks
  This parameter does not need a reload of the effect to be taken into account.

## ◆ setCamera()

void nkAstraeus::DofComplexEffect::setCamera | ( | nkGraphics::Camera * | value | ) |

Sets the camera used to retrieve the projection parameters from. Defaults to nullptr, retrieving the camera information from the active context's camera.

Parameters

  value | The camera to use to get the projection information.

Remarks
  This parameter does not need a reload of the effect to be taken into account.

## ◆ setNearPlaneDistance()

void nkAstraeus::DofComplexEffect::setNearPlaneDistance | ( | float | value | ) |

Sets the near plane distane, in world units, from the camera. All pixels closer than this distance will get fully blurred. Between the focal plane and the near plane, pixels will gradually get blurrier as they approach the near plane.

Parameters

  value | The near distance, in world units.

Remarks
  This parameter does not need a reload of the effect to be taken into account.

## ◆ setFocalPlaneDistance()

void nkAstraeus::DofComplexEffect::setFocalPlaneDistance | ( | float | value | ) |

Sets the focal plane distane, in world units, from the camera. This distance is the one for which the pixels will be in focus and thus sharp. As pixels get closer to the near or far plane, they will get blurrier.

Parameters

  value | The focal distance, in world units.

Remarks
  This parameter does not need a reload of the effect to be taken into account.

## ◆ setFocalPlaneThickness()

void nkAstraeus::DofComplexEffect::setFocalPlaneThickness | ( | float | value | ) |

Sets the focal plane thickness, in world units. The focal plane defines pixels that are in focus. The plane thickness defines how tolerant the focal plane is, allowing pixels found at a distance from the focal plane smaller than half its thickness to be in focus.

Parameters

  value | The plane thickness, in world units.

Remarks
  This parameter does not need a reload of the effect to be taken into account.

## ◆ setFarPlaneDistance()

void nkAstraeus::DofComplexEffect::setFarPlaneDistance | ( | float | value | ) |

Sets the far plane distane, in world unit, from the camera. All pixels further away than this distance will get fully blurred. Between the focal plane and the far plane, pixels will gradually get blurrier as they approach the far plane.

Parameters

  value | The far distance, in world unit.

Remarks
  This parameter does not need a reload of the effect to be taken into account.

## ◆ setBlurStrength()

void nkAstraeus::DofComplexEffect::setBlurStrength | ( | unsigned int | value | ) |

Sets the blurring strength when reaching either the near or far plane. This can be interpreted as the the final blurring radius. Defaults to 3.

Parameters

  value | The blurring strength to apply.

Remarks
  This parameters needs the effect to be reloaded if need be, to be taken into account.

## ◆ setLinearDepth()

void nkAstraeus::DofComplexEffect::setLinearDepth | ( | bool | value | ) |

Sets whether the depth information texture should be considered linear, or not. Linear depth information will be between [0, 1] and simply be mapped to the camera's settings (near + depth * (far - near)). If not linear, then the camera's projection parameter will be used to reconstruct linear depth before deducing the depth in world units. Defaults to false.

Parameters

  value | Whether depth data should be considered as already linear (true) or not (false).

Remarks
  This parameter needs the effect to be reloaded if need be, to be taken into account.

## ◆ load()

virtual bool nkAstraeus::DofComplexEffect::load | ( |  | ) |
| override virtual

Loads the effect and make it ready for rendering. After a successful call, this means the compositor node will be populated with the relevant data.

Returns
  Whether the loading went well (true) or not (false).

Implements nkAstraeus::ComplexEffect.

## ◆ unload()

virtual void nkAstraeus::DofComplexEffect::unload | ( |  | ) |
| override virtual

Unloads the effect and its internal memory. After that, the effect is unusable for rendering. The compositor node specified will be cleaned from all linked operations.

Implements nkAstraeus::ComplexEffect.

## ◆ create()

static nkMemory::UniquePtr<DofComplexEffect> nkAstraeus::DofComplexEffect::create | ( | System * | system = `nullptr` | ) |
| static

Creates an instance of the class, and returns ownership over it.

Parameters

  system | The system the resource should live in. If left to nullptr, will seek the singleton instance of the system.

Returns
  Ownership over the created instance of the class.

Remarks
  The instance is not part of any manager if instantiated this way. If the resource's lifetime should be managed within the manager, then calling ComplexEffectManager::createOrRetrieve() might be a better option. Alternatively, registering it afterwards through ComplexEffectManager::record() is another option.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsAstraeus/Graphics/ComplexEffects/Dof/DofComplexEffect.h